package com.spatio.serving.basic.service.template.common.util;

import java.util.Random;

public class ValidateCodeutils {
    public static String generateValidateCode4String(int length){
        if (length <= 0) {
            throw new IllegalArgumentException("Length must be greater than 0");
        }

        Random random = new Random();
        StringBuilder sb = new StringBuilder(length);
        for (int i = 0; i < length; i++) {
            int digit = random.nextInt(10); // 生成 0 到 9 的随机数字
            sb.append(digit);
        }
        return sb.toString();

    }

}